package com.geoway.adf.report.config;

import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.databind.DeserializationContext;
import com.fasterxml.jackson.databind.JsonDeserializer;
import com.fasterxml.jackson.databind.JsonNode;

import java.io.IOException;

public class EmptyToNullObject<T> extends JsonDeserializer<T> {

  @Override
  public T deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException {
    JsonNode node = jp.getCodec().readTree(jp);
    if(null == node || node.isEmpty()){
      return null;
    }else {
     return null;
    }

  }
}